//
//  XSAVPlayer.h
//  AudioVideo
//
//  Created by xueshan1 on 2019/8/23.
//  Copyright © 2019 xueshan1. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "XSAVPlayerDelegate.h"
#define kWeakSelf __weak __typeof(&*self)weakSelf = self;

typedef NS_ENUM(NSUInteger, XSAVPlayerSessionCategory) {
    XSAVPlayerSessionCategory_Ambient,    //用于播放,随用户锁屏和静音而静音,不终止其他播放声音
    XSAVPlayerSessionCategory_SoloAmbient,//用于播放,随用户锁屏和静音而静音,终止其他播放声音
    XSAVPlayerSessionCategory_Playback,   //用于播放,不随用户锁屏和静音而静音,终止其他播放声音(需设置后台播放background mode)
};


@interface XSAVPlayer : NSObject

#pragma mark --状态
//播放器状态
@property(nonatomic,readonly,assign)XSAVPlayerState playState;
//播放进度
@property(nonatomic,assign)CGFloat sf_progress;
//进度变化回调
@property(nonatomic,copy)void(^progressChangeBlock)(CGFloat sf_progress);
//当前播放时长
@property(nonatomic,assign)CGFloat sf_currentTime;
//总时长
@property(nonatomic,assign)CGFloat sf_totalTime;
//缓冲进度
@property(nonatomic,assign)CGFloat sf_bufferProgress;

#pragma mark - 控制
//播放类别
@property(nonatomic,assign)XSAVPlayerSessionCategory sessionCategory;
//是否循环播放 default NO
@property(nonatomic,assign)BOOL isRecyclePlay;
//播放速度
@property(nonatomic,assign)CGFloat sf_rate;
//设置播放进度 0~1
@property(nonatomic,assign)CGFloat progressValus;
//自定义缓存default NO (系统将不会自动加载)
@property(nonatomic,assign)BOOL needCustomeCache;

@property(nonatomic,weak)id delegate;

+ (instancetype)shareInstance;

+ (instancetype)audioInstance;
//初始化
- (void)initPlayer;
//播放音频
- (void)sf_playAudioWithURL:(NSURL *)audioURL isLocalFile:(BOOL)isLocal;
- (void)sf_playAudioWithURLString:(NSString *)audioURLString isLocalFile:(BOOL)isLocal;

//播放(第一次播放不需要调用)
- (void)sf_audioPlay;
//暂停
- (void)sf_audioPause;
//释放播放器
- (void)sf_deallocPlayer;

#pragma mark - 视频
- (void)playVideoWithURLString:(NSString *)urlString onPlayView:(UIView *)playView isLocalFile:(BOOL)isLocal;
- (void)playVideoWithURLString:(NSString *)urlString onPlayView:(UIView *)playView belowView:(UIView *)belowView  isLocalFile:(BOOL)isLocal;
- (void)playVideoWithPlayItem:(AVPlayerItem *)playItem onPlayView:(UIView *)playView belowView:(UIView *)belowView;
- (void)playVideoWithAVAsset:(AVAsset *)avasset onPlayView:(UIView *)playView belowView:(UIView *)belowView;

//视频宽高比
@property(nonatomic,assign,readonly)CGFloat videoScale;
//播放开始/截止的时间点
@property(nonatomic,assign)CGFloat playStartTimePercent;
@property(nonatomic,assign)CGFloat playStopTimePercent;
//音量
@property(nonatomic,assign)CGFloat volumn;



@end

